#include "../client/rpc_client.hpp"
#include "../common/detail.hpp"
#include <thread>
using namespace rpc;

void callback(const Json::Value &result)
{
    std::cout<< "result: " << result.asInt() << std::endl;
}

int main()
{

    rpc::client::RpcClient client(false, "127.0.0.1", 8080);

    Json::Value params, result;
    params["num1"] = 11;
    params["num2"] = 22;
    bool ret = client.call("Add", params, result);
    if(ret)
    {
        std::cout<<"result:" << result.asInt() <<std::endl;
    }

    params["num1"] = 33;
    params["num2"] = 55;
    rpc::client::RpcCaller::JsonAsyncResponse res_future;
    ret = client.call("Add", params, res_future);
    if(ret)
    {
        result = res_future.get();
        std::cout<< "result:" << result.asInt() << std::endl;
    }

    params["num1"] = 66;
    params["num2"] = 77;
    client.call("Add", params, callback);

    DLOG("--------\n");
    std::this_thread::sleep_for(std::chrono::seconds(2));

    return 0;
}